//
//  SpeciesPickerViewController.m
//  IphoneFishApp
//
//  Created by erik on 2009-10-21.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "SpeciesPickerViewController.h"


@implementation SpeciesPickerViewController
@synthesize pickerView;
@synthesize arraySpecies;
@synthesize actionSheet;
@synthesize speciesValue;
@synthesize parent;


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
	
	arraySpecies = [[NSMutableArray alloc]init];
	
	[arraySpecies addObject:@"Pike"];
	[arraySpecies addObject:@"Salmon"];
	[arraySpecies addObject:@"Bass"];
	[arraySpecies addObject:@"Red herring"];
	[arraySpecies addObject:@"Trout"];
	self.speciesValue = @"Pike";
}

-(IBAction)chooseSpecies:(id)sender{
	UIActionSheet *speciesSheet = [self actionSheet];
	[speciesSheet dismissWithClickedButtonIndex:0 animated:YES];
	
	self.parent = (catchViewController *)self.parent;
	[parent changeSpecies:speciesValue];
}

-(IBAction)cancelSpecies:(id)sender{
	UIActionSheet *weightSheet = [self actionSheet];
	[weightSheet dismissWithClickedButtonIndex:0 animated:YES];
}


- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView {
	return 1;
}

- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {
	return [arraySpecies count];
}

- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
	return [arraySpecies objectAtIndex:row];
}

- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
	
	self.speciesValue = [arraySpecies objectAtIndex:row];
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}

- (void)dealloc {
    [super dealloc];
	[pickerView release];
}


@end
